﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using Axis.Dao.Partner;
using Axis.BusinessObject;

namespace Sotipha.Web.Views.Partner
{
    public class CPartnerUI : CPage
    {
        public string GetList()
        {
            StringBuilder Result = new StringBuilder();
            CPartnerDao coreProduct = new CPartnerDao();
            IList<CPartner> listProduct = coreProduct.GetPartner(string.Format("<InputValue Context=\"FrontEnd\"/>"));
            string Language = Session["lang"].ToString();
            string Parttern = " <li><a href=\"{0}\">" +
                            "<img src=\"{1}\" address=\"{2}\" phone=\"{3}\" website=\"{4}\" name=\"{5}\"/></a></li>";
            string Pattern2 = "<li class=\"item\"> <ul>{0}</ul></li>";
            string liItem = "";
            if (listProduct != null)
                if (listProduct.Count > 0)
                {
                    for (int i = 0; i < listProduct.Count; i++)
                    {
                        var Item = listProduct[i];
                        if (i > 0 && i % 12 == 0)
                        {
                            Result.AppendFormat(Pattern2, liItem);
                            liItem = "";
                        }
                        liItem += string.Format(Parttern, Item.Link, Item.Thumbnail, Item.Address, Item.Phone, Item.Website, Item.Name);
                        if (i > 0 && (i == listProduct.Count - 1 || i % 12 == 0))
                            Result.AppendFormat(Pattern2, liItem);
                    }

                }
            return Result.ToString();
        }
    }
}